import React from 'react';
import { Form, Radio, FormInstance } from 'antd';

interface TrueFalseFormProps {
  form: FormInstance;
}

const TrueFalseForm: React.FC<TrueFalseFormProps> = ({ form }) => {
  // 判断题固定选项
  const choices = [
    { key: 'A', content: '正确' },
    { key: 'B', content: '错误' },
  ];

  // 自动设置choices
  React.useEffect(() => {
    form.setFieldsValue({ choices });
  }, [form]);

  return (
    <div>
      <Form.Item
        name="correct_answers"
        label="正确答案"
        rules={[{ required: true, message: '请选择正确答案' }]}
      >
        <Radio.Group>
          <Radio value="A" style={{ display: 'block', marginBottom: 12 }}>
            <strong>正确</strong>
          </Radio>
          <Radio value="B" style={{ display: 'block' }}>
            <strong>错误</strong>
          </Radio>
        </Radio.Group>
      </Form.Item>

      {/* 隐藏字段 */}
      <Form.Item name="choices" hidden>
        <input />
      </Form.Item>
    </div>
  );
};

export default TrueFalseForm;

